<?php
/**
 * o2o门店线下仓库
 *
 * @access public
 * @author wangbiao<wangbiao@shopex.cn>
 * @version $Id: regions.php 2016-03-29 20:00
 */
class o2o_store_branch
{
    /**
     * 获取操作员管辖的o2o门店线下仓库
     *
     * @param intval $region_id
     * @return Array
     */
    public function getO2OBranchByUser($dataType=null)
    {
        $oBops    = app::get('o2o')->model('branch_ops');
        
        $opInfo = kernel::single('ome_func')->getDesktopUser();
        $op_id = $opInfo['op_id'];

        $filter    = array('op_id' => $op_id);

        $bops_list = $oBops->getList('branch_id', $filter, 0, -1);
        if ($bops_list)
        {
            foreach ($bops_list as $k => $v)
            {
                $bps[] = $v['branch_id'];
            }
        }
        
        if ($dataType)
        {
            return $bps;
        }
        
        if ($bps)
        {
            $Obranch  = app::get('ome')->model('branch');
            $branch_list = $Obranch->getList('branch_id,name,uname,phone,mobile', array('branch_id' => $bps), 0, -1);
        }
        
        if ($branch_list)
        {
            ksort($branch_list);
        }
        
        return $branch_list;
    }
}
